package cn.jsu.oj.dispatchServer.handle.handles.checkinfohandles;

import cn.jsu.oj.dispatchServer.handle.CommandPack;
import cn.jsu.oj.dispatchServer.handle.handles.Handle;
import cn.jsu.oj.dispatchServer.init.WebClient;
import cn.jsu.oj.dispatchServer.net.DispatchServerHandle;
import cn.jsu.oj.dispatchServer.parsing.HandleType;
import cn.jsu.oj.dispatchServer.pojo.CmdInformation;
import cn.jsu.oj.dispatchServer.pojo.checkinfo.WebAbstractCheckInfo;
import cn.jsu.oj.dispatchServer.resource.Resource;
import lombok.extern.slf4j.Slf4j;

import java.util.Set;

/**
 * @author 24987
 */

@Slf4j
@HandleType(type = 95)
public class WebCheckInfoHandle implements Handle {

    @Override
    public CommandPack<?> handle(CommandPack<?> pack) {
        log.info("----------主观提交服务开始验证......");
        WebAbstractCheckInfo checkInfo = (WebAbstractCheckInfo) pack.getData();
        System.out.println("ip" + pack.getIp());
        if (checkInfo.getPassword().equals(Resource.WEB_PASSWORD)) {
            log.info("WEB端验证密码正确 IP:" + pack.getIp());
            return new CommandPack<>(pack.getIp(), new WebClient());
        }
        log.info("WEB端验证密码错误 IP:" + pack.getIp());
        return null;
    }
}